﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace dpdw.CompoundPattern
{
    /// <summary>
    /// 鸭子叫计数器 装饰者模式
    /// </summary>
    public class QuackCounter : IQuackable
    {
        IQuackable duck;
        static int numberOfQuacks = 0;

        public QuackCounter(IQuackable duck)
        {
            this.duck = duck;
        }

        public void Quack()
        {
            duck.Quack();
            numberOfQuacks++;
        }

        /// <summary>
        /// 叫声数量
        /// </summary>
        /// <returns></returns>
        public static int GetQuacks()
        {
            return numberOfQuacks;
        }
    }
}
